<template>
    <div style="margin: 0 10px 0 10px">
        <div style="margin: 10px">
            求助标题: <Input v-model="dataFilter.helpTitle" size="small" placeholder="" style="width: 120px" />
            <Button type="primary" shape="circle" icon="ios-search" style="margin-left: 15px" @click="loadData"></Button>
        </div>
        <Table :data="tableData"  :columns="columns"    :loading="loading">
            <template slot-scope="{ row }" slot="action">
                <!--<Button type="primary" size="small" style="margin-right: 5px" @click="handleView(row,index)">查看</Button>-->
                <Button type="primary" size="small" style="margin-right: 5px" :to="{ name: 'donate_donate_edit', query: { id:row.id } }">编辑</Button>
                <Button type="error" size="small" @click="handleRemove(row,index)">删除</Button>
            </template>
            <template slot-scope="{ row }" slot="auditResult">
                {{auditResultDict(row.auditResult)}}
            </template>
        </Table>
        <div style="margin: 25px;overflow: hidden">
            <div style="float: right;">
                <Page :total="total" :current="dataFilter.current" :page-size="dataFilter.size"
                      show-sizer
                      @on-change="changePage" @on-page-size-change="changeSize" :page-size-opts="[10,20,50,100]"></Page>
            </div>
        </div>
    </div>
</template>
<script>
    import Base from '@/components/table/BaseList';
    import user from '@/common/user';
    import dictUtils from '@/common/dictUtils';
    export default {
        components:{ },
        extends:Base,
        data () {
            return {
                columns: [
                    { type: 'index', width: 60, align: 'center'},
                    { title: '求助标题', key: 'helpTitle'},
                    { title: '捐赠类型', key: 'type'},
                    { title: '捐赠内容详情', key: 'content'},
                    { title: '求助人', key: 'helpUserName', width: 150},
                    { title: '状态', key: 'auditResult',slot: 'auditResult', width: 100},
                    { title: '操作', key: 'action',slot: 'action', width: 200, align: 'center'}
                ]
            }
        },
        mounted(){
            this.dataFilter. donatorId=user.getUser().id;
            this.loadData();
        },
        methods: {
            handleEdit(){
                //编辑功能
            },
            loadData(){
                //获取列表数据
                this.baseLoadData('/api/donate/list', ()=>{
                        dictUtils.decodeList('donate_type',this.tableData,"type")
                    }
                );
            },handleRemove(row){
                //删除
                this.baseRemove('/api/donate/delete',{id:row.id});
            },
            auditResultDict(auditResult){
                if(auditResult==null  ||  auditResult==""  ||  auditResult=="00"){
                    return "待审核";
                }else if(auditResult == "01"){
                    return "审核通过";
                }else{
                    return "审核不通过";
                }
            }
        }
    }
</script>
